<html>
<head>
    <title>确认支付</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
</head>
<body>
<input type="hidden" name="appId" value="${e.appId}">
<input type="hidden" name="nonceStr" value="${e.nonceStr}">
<input type="hidden" name="prepayId" value="${e.package}">
<input type="hidden" name="paySign" value="${e.paySign}">
<input type="hidden" name="timeStamp" value="${e.timeStamp}">
</body>
<script>
    function onBridgeReady() {
        var appId = $("input[name='appId']").val();
        var nonceStr = $("input[name='nonceStr']").val();
        var prepayId = $("input[name='prepayId']").val();
        var paySign = $("input[name='paySign']").val();
        var timeStamp = $("input[name='timeStamp']").val();
        WeixinJSBridge.invoke('getBrandWCPayRequest', {
            "appId" : appId,
            "timeStamp" : timeStamp,
            "nonceStr" : nonceStr,
            "package" : prepayId,
            "signType" : "MD5",
            "paySign" : paySign
        }, function(res) {
            console.log(res)
            if (res.err_msg == "get_brand_wcpay_request:ok") {
                alert("搞定了");
            } else {//这里支付失败和支付取消统一处理
                alert(res.err_msg);
            }
        });
    }

    $(document).ready(
            function() {
                if (typeof WeixinJSBridge == "undefined") {
                    if (document.addEventListener) {
                        document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                        console.log(1);
                    } else if (document.attachEvent) {
                        console.log(3);
                        document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                        document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                    }
                } else {
                    console.log(2);
                    onBridgeReady();
                }
            });
</script>
</html>